import { across, bet } from '@prisma/client'
import { AbstractCalculate } from './AbstractCalculate'

export class NiOrderCalculate extends AbstractCalculate {
  adjustOrder(lst_bet: bet[], lst_across: across[]) {
    // update lst_bet
    lst_bet.reverse()
    lst_bet.map((bet) => {
      const [tName1, tName2] = bet.btName.split('--')
      bet.btName = tName2 + '--' + tName1
    })

    // update lst_across
    lst_across.map((across) => {
      const [tName1, tName2] = across.btName.split('--')
      across.btName = tName2 + '--' + tName1

      // update acrossx
      const bet = lst_bet.find((bet) => bet.btName === across.btName)
      across.acrossX = bet.btSpan - across.acrossX
    })

    return { lst_bet, lst_across }
  }
}
